#pragma once
#include<string>
#include<fstream>
#include<iostream>
#include "Subject.h"
#include "Observer.h"
class Dipan : public Observer
{
    public:
    string id;
    string xinghao;
    string zhouju;
    string lunju;
    string ldjx;
    string zwbj;
    string qudong;
    string xingcheng;
    string luntai;
    string ltxinghao;
    string ltcc;
    string zhuangtai;
    void set(string id,string xinghao,string zhouju,string lunju,string ldjx,string zwbj,string qudong,string xingcheng,string luntai,string ltxinghao,string ltcc)
    {
        this->id=id;
        this->xinghao=xinghao;
        this->zhouju=zhouju;
        this->lunju=lunju;
        this->ldjx=ldjx;
        this->zwbj=zwbj;
        this->qudong=qudong;
        this->xingcheng=xingcheng;
        this->luntai=luntai;
        this->ltxinghao=ltxinghao;
        this->ltcc=ltcc;
    }
    void get();
    void save();
    void update(Subject *subject)
    {
        zhuangtai=subject->getState();
        if(zhuangtai=="2")
        {
            cout<<"后退 -1"<<endl;
        }
        else if(zhuangtai=="3")
        {
            cout<<"向左转 2"<<endl;
        }
        else if(zhuangtai=="4")
        {
            cout<<"向右转 -2"<<endl;
        }
        else if (zhuangtai == "1")
        {
            cout<<"直走 1"<<endl;
        }
    }
};
void Dipan::get()
{
    cout<<"底盘编号:"<<id<<","<<"型号:"<<xinghao<<","<<"轴距:"<<zhouju<<","<<"轮距:"<<lunju<<endl;
    cout<<"最小离地间隙:"<<ldjx<<","<<"最小转弯半径:"<<zwbj<<","<<"驱动形式:"<<qudong<<","<<"最大行程:"<<xingcheng<<endl;
    cout<<"轮胎:"<<luntai<<","<<"轮胎型号:"<<ltxinghao<<","<<"轮胎尺寸"<<ltcc<<endl;
}
void Dipan::save()
{
    ofstream f;
    f.open("car.txt",ios::out|ios::app);
    f<<id<<" "<<xinghao<<" "<<zhouju<<" "<<lunju<<" "<<ldjx<<" "<<zwbj<<" "<<qudong<<" "<<xingcheng<<" "<<luntai<<" "<<ltxinghao<<" "<<ltcc<<endl;
    f.close();
}
class Lidar : public Subject
{
    public:
    string xinghao;
    string tds;
    string csfw;
    string gonghao;
    string zhangai;
    void set(string xinghao,string tds,string csfw,string gonghao)
    {
        this->xinghao=xinghao;
        this->tds=tds;
        this->csfw=csfw;
        this->gonghao=gonghao;
    }
    void get();
    void save();
    string getState()
    {
        return zhangai;
    }
    void setState(string s)
    {
        zhangai=s;
    }
};
void Lidar::get()
{
    cout<<"多线激光雷达型号:"<<xinghao<<","<<"通道数:"<<tds<<","<<"测试范围:"<<csfw<<","<<"功耗"<<gonghao<<endl;
}
void Lidar::save()
{
    ofstream f;
    f.open("car.txt",ios::out|ios::app);
    f<<xinghao<<" "<<tds<<" "<<csfw<<" "<<gonghao<<endl;
    f.close();
}